using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_DiaDiemThem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
           
    }


    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
           tbDiaDiem diadiem=new tbDiaDiem ();
           diadiem.TenDD = txt_tendiadiem.Text;
           diadiem.DiaChi = txt_diachi.Text;
           diadiem.DienThoai = txt_dienthoai.Text;
           if (fu_bando.HasFile)
           {
               string filename = DateTime.Now.Ticks.ToString() + "_" + fu_bando.FileName;
               fu_bando.SaveAs(Server.MapPath("~/Photos/" + filename));

               System.Drawing.Image img = System.Drawing.Image.FromFile(
                   Server.MapPath("~/Photos/" + filename));
               ImageUtility.MakeThumbnailPhoto(img, 100, 100, Server.MapPath("~/Photos/Thumb/"), filename);
               diadiem.BanDo = filename;
           }
           else
           {
               diadiem.BanDo = "hinh.jpg";
           }
           tbDiaDiemBUS.Insert(diadiem);
           Response.Redirect("~/Admin/DiaDiemDanhSach.aspx");
        }
        catch (Exception ex)
        {

        }
        Response.Redirect("~/Admin/DiaDiemDanhSach.aspx");
    }
}
